#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
using namespace std;


class MyQueue {
public:
    /** Initialize your data structure here. */
    MyQueue() {

    }
    
    /** Push element x to the back of queue. */
    void push(int x) {
        //先把B中的元素倒回到A中去
        while(!B.empty()){
            A.push(B.top());
            B.pop();
        }
        A.push(x);
    }
    
    /** Removes the element from in front of queue and returns that element. */
    int pop() {
        //将A中的内容移到B上去
        while(!A.empty()){
            B.push(A.top());
            A.pop();
        }
        if(B.empty()){
            return -1;
        }
        else{
            int A = B.top();
            B.pop();
            return A;
        }
    }
    
    /** Get the front element. */
    int peek() {
        //将A中的内容移到B上去
        while(!A.empty()){
            B.push(A.top());
            A.pop();
        }
        if(B.empty()){
            return -1;
        }
        else{
            return B.top();
        }
    }
    
    
    /** Returns whether the queue is empty. */
    bool empty() {
        while(!A.empty()){
            B.push(A.top());
            A.pop();
        }
        return B.empty();
    }
public:
    stack<int> A;
    stack<int> B;
};

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue* obj = new MyQueue();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->peek();
 * bool param_4 = obj->empty();
 */